package com.work.chat.custom.server.config.exception;

import com.work.chat.common.eums.BizCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 全局异常处理
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException {
    private Integer code;
    private String message;

    public BizException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BizException(BizCodeEnum bizCodeEnum) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.message = bizCodeEnum.getMessage();
    }

    public BizException(String msg) {
        super(msg);
        this.code = 500;
        this.message = msg;
    }
}